package com.hyf.okhttp3demo.support;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2017/12/14.
 */

public class DownLoadFileInterceptor implements Interceptor {

    private ProgressResponseBody.ProgressListener mListener;

    public DownLoadFileInterceptor(ProgressResponseBody.ProgressListener listener) {
        mListener = listener;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Response response = chain.proceed(request);
        return response.newBuilder().body(new ProgressResponseBody(response.body(), mListener)).build();
    }
}
